﻿@{
    Layout = null;
}
@model RiderShop.Mobile.Modle.Product.ProductListModel


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>App上线钜惠，鲜蛋随心砸，好礼等君来，用心才会极致，好货不将就！</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="~/Themes/RongJi/Style/categoryproduct/css/style.css" rel='stylesheet' type='text/css' />
</head>
<body>
    <div class="wrapper">
        <img id="imgHeader" src="~/Themes/RongJi/Style/categoryproduct/images/top.png" class="fullWidth">
        <div class="box-10 wrapperinner">
            <a href="http://m.rongji365.com/WeixinPortal/Activity/SpecificSmashingGoldenEgg?activityID=111&portal=rongji365" id="zajindan"><img src="~/Themes/RongJi/Style/categoryproduct/images/golden-egg.jpg" class="fullWidth bannerAD"></a>
            <div id="Tabs">
                @{
                    List<int> cates = new List<int>() { 0, 0, 0 };
                    List<string> keywords = new List<string>() { "APP钜惠36折", "APP钜惠56折", "APP钜惠86折" };
                    //List<string> keywords = new List<string>() { "键盘", "鼠标", "电脑" };
                    List<string> catesName = new List<string>() { "钜惠36折", "钜惠56折", "钜惠86折" };
                }

                <ul class="mm_tab">
                    @for (int i = 0; i < cates.Count; i++)
                    {
                        <li><a href="#Tabs@(i)" style="width:@(100.0 / cates.Count)%"><span>@catesName[i]</span></a></li>
                    }
                </ul>
                @for (int i = 0; i < cates.Count; i++)
                {
                    Kevin.Shop.Business.Products.Components.ProductQuery query1 = new Kevin.Shop.Business.Products.Components.ProductQuery()
                    {
                        PageIndex = 0,
                        PageSize = Kevin.Shop.Business.Service.Entity.Helper.WebClientContext.CON_PageSize,
                        CategoryId = cates[i],
                        Keyword = keywords[i],
                        IsWebsiteSearch = true
                    };
                    var result1 = Model.GetProducts(query1);
                    if (result1 != null && result1.Data != null)
                    {
                        <div id="Tabs@(i.ToString())">
                            <ul class="items" categoryid="@cates[i]" pageindex="0" totalcount="@result1.TotalRecords" totalpage="@Model.TotalPage" keyword="@keywords[i]">
                                @foreach (var product in result1.Data)
                                {
                                    <li>
                                        <a href="/Product/ProductDetail?prd=@(product.ProductId)">
                                            <img src="@product.ActualImageUrl" />
                                        </a>
                                        <h2>@(product.Title)</h2>
                                        <span class="price">￥@(product.UnitPrice.ToString("N2"))</span>
                                        <span class="marketprice">￥@(product.MarketPrice.ToString("N2"))</span>
                                        <a href="/Product/ProductDetail?prd=@(product.ProductId)" class="btn-buy">立即抢购</a>
                                    </li>
                                }
                            </ul>

                        </div>
                    }
                    else
                    {
                        <div id="Tabs@(i.ToString())">
                            暂无商品
                        </div>
                    }

                }
            </div>


            <div id="loading_bottom" style="margin-top:-10px;display:none;">加载中...</div>
            <div id="showMore" style="margin-top:-10px;display:none;">加载中...</div>
        </div>
    </div>


    @if (Request.UserAgent.ToUpper().Contains("ANDROID"))
    {
        <div class="appmask">
            <ul>
                <li>下载蓉记鲜鲜鲜手机客户端,下单送好礼</li>
                <li class="btn-down">立即下载</li>
            </ul>
        </div>
    }
    <script src="http://www.rongji365.com/Themes/RongJi/Style/plugins/jquery.min.js"></script>
    <script src="http://m.rongji365.com/Utility/pages/jquery.cookie.js"></script>
    <script src="http://m.rongji365.com/staticResource/nianhuo2015/statics/js/aTabs.js"></script>
    <script>
        var isloading = false;
        var topHeight = $('#zajindan img').height() + $('#imgHeader').height();

        $(window).bind("scroll", function () {
            if (isloading) {
                return;
            }


            if ($(window).scrollTop() - $(window).height() + $('.mm_tab').height() * 2 > 0) {
                $("#Tabs").css({ 'padding-top': "62px" });
                $('.mm_tab').addClass('fixed');
            }
            else {
                $("#Tabs").css('padding-top', "0px");
                $('.mm_tab').removeClass('fixed');
            }


            if ($(document).scrollTop() + $(window).height() + 20 >= $(document).height()) {
                LoadProduct();
            }
        });


        function LoadProduct() {
            if (isloading) {
                return;
            }
            var selectedTab = $('li.selected', $('.mm_tab'));
            var selectedTabId = $('a', selectedTab).attr('href');
            var selectedUl = $('ul', $(selectedTabId));

            var totalPage = parseInt(selectedUl.attr('totalpage'));
            var pageIndex = parseInt(selectedUl.attr('pageindex'));
            var categoryId = parseInt(selectedUl.attr('categoryid'));
            var keyword = selectedUl.attr('keyword');
            var args = "";
            if (pageIndex + 1 === totalPage) {
                $("#showMore").show().html('加载完毕').delay(2300).slideUp(1600);
                return;
            }
            $("#loading_bottom").show();
            isloading = true;

            args = "page=" + pageIndex + "&sid=" + categoryId + "&keyword=" + keyword;
            $.ajax({
                type: "GET",
                url: 'ProductListByAjaxRequest?' + args,
                dataType: "JSON",
                success: function (response) {
                    isloading = false;
                    if (response.length) {
                        selectedUl.attr('pageindex', parseInt(pageIndex) + 1);
                    }
                    $("#loading_bottom").hide();
                    /*---------------------半透明慢慢的滑动上来,在向上滑动过程中越来越明显--------------------*/

                    $.each(response, function (key, value) {
                        var html = '<li style="opacity:0;margin-top:10px">'
                        + ' <a href="/Product/ProductDetail?prd=' + value.ProductId + '">'
                        + '<img src="' + value.ActualImageUrl + '" />'
                        + '  </a>'
                        + '  <h2>' + value.Title + '</h2>'
                        + '  <span class="price">￥' + value.UnitPrice + '</span>'
                        + '<span class="marketprice">￥' + value.MarketPrice + '</span>'
                        + '   <a href="/Product/ProductDetail?prd=' + value.ProductId + '" class="btn-buy">立即抢购</a>'
                         + '</li>';
                        var aaa = $(html);
                        selectedUl.append(aaa);
                        aaa.animate({ opacity: '1', marginTop: 0 }, 1000);
                    });
                }
            });
        }


        $(document).ready(function () {
            $('#Tabs').aTabs({
                eventName: 'click',

            });

            $('#Tabs li').click(function () {
                if (topHeight < $(window).scrollTop()) {
                    $(window).scrollTop(topHeight);
                }
            })
        });



    </script>

    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript">

        window.config = {
            link: 'http://www.rongji365.com/app/index.html',
            imgUrl: 'http://m.rongji365.com/Storage/CommResource/sicon.jpg',
            img_url: 'http://m.rongji365.com/Storage/CommResource/sicon.jpg',
            title: '【蓉记鲜鲜鲜】',
            desc: 'App上线钜惠，鲜蛋随心砸，好礼等君来，用心才会极致，好货不将就！',

        };
        window.timelineconfig = {
            link: 'http://www.rongji365.com/app/index.html',
            imgUrl: 'http://m.rongji365.com/Storage/CommResource/sicon.jpg',
            img_url: 'http://m.rongji365.com/Storage/CommResource/sicon.jpg',
            title: '【蓉记鲜鲜鲜】App上线钜惠，鲜蛋随心砸，好礼等君来，用心才会极致，好货不将就！',
        };
        function onBridgeReady() {
            WeixinJSBridge.call('showOptionMenu');
        }

        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }

        document.addEventListener('WeixinJSBridgeReady', function () {
            var WJ = WeixinJSBridge;

            WJ.on('menu:share:appmessage', function () {
                WJ.invoke('sendAppMessage', config, function (res) {
                    // _report('sendAppMessage', res.err_msg);
                });
            });

            WJ.on('menu:share:timeline', function () {
                config.title = config.title + config.desc;
                WJ.invoke('shareTimeline', config, function (res) {
                    // _report('shareTimeline', res.err_msg);
                });
            });

            WJ.on('menu:share:weibo', function () {
                WJ.invoke('shareWeibo', config, function (res) {
                    // _report('shareWeibo', res.err_msg);
                });
            });
        });

        $(function () {
            var postData = {
                "currentUrl": location.href.split('#')[0]
            }
            $.post("/WeixinJsSdk/ConfigScriptJson", postData, function (wxConfig) {
                //wxConfig = JSON.parse(wxConfig);
                //wxConfig.debug = true;
                wxConfig.jsApiList.push("showOptionMenu");
                wx.config(wxConfig);

                wx.ready(function () {

                    var config = window.config;
                    wx.onMenuShareAppMessage(config);
                    wx.onMenuShareTimeline(window.timelineconfig);
                    wx.onMenuShareQQ(config);
                    wx.onMenuShareWeibo(config);

                    wx.showOptionMenu();
                });

                wx.error(function (res) {

                });
            });
        });
    </script>
    <!--Static Code Start-->
    <script type="text/javascript" src="http://js.tongji.linezing.com/3547905/tongji.js"></script>
    <script type="text/javascript">
        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fd2c430d3acdc174f29f6feef73ea35fa' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <!-- Piwik -->
    <script type="text/javascript">
        var _paq = _paq || [];
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function () {
            var u = "//analytics.it-hsmedia.com/";
            _paq.push(['setTrackerUrl', u + 'piwik.php']);
            _paq.push(['setSiteId', 2]);
            var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
            g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s);
        })();
    </script>
    <noscript>
        <p>
            <img src="//analytics.it-hsmedia.com/piwik.php?idsite=2" style="border: 0;" alt="" />
        </p>
    </noscript>
    <!-- End Piwik Code -->
    <!--Static Code End-->
</body>
</html>